<template>
	<view class="container">
		<!-- 用户信息 -->
		<!-- # indef MP-wei -->
		<!-- <view class="userinfo">
    <view class="userinfo-avatar">
      <open-data type="userAvatarUrl"></open-data>
    </view>
    <view class="userinfo-name">
      <open-data type="userNickName"></open-data>
    </view>
  </view>
  <view class="binding-phone">
    <text class="show-tip">绑定手机号后可查看订单和领取优惠券，</text>
    <text class="gotobinding" @tap="toBindingPhone">去绑定</text>
  </view> -->

		<view class="userinfo" v-if="isLogin">
			<view class="userinfo-con">
				<view class="userinfo-avatar">
					<!-- <open-data type="userAvatarUrl"></open-data> -->
					<image :src="userInfo.avatar"></image>
				</view>
				<view class="userinfo-name">
					<view>{{ userInfo.name }}</view>
				</view>
			</view>
		</view>

		<view class="userinfo-none" v-if="!isLogin">
			<view class="default-pic" @click="toLogin">
				<image src="../../static/logo.png"></image>
			</view>
			<view class="none-login" @click="toLogin">
				<button class="unlogin">未登录</button>
				<button class="click-login">点击登录账号</button>
			</view>
		</view>
		<!-- end 用户信息 -->

		<view class="list-cont">

			<!-- 订单状态 -->
			<view class="total-order">
				<view class="order-tit">
					<text style="font-weight:bold">我的订单</text>
					<view class="checkmore" @tap="toOrderListPage" data-sts="0">
						<text>查看全部 </text>
						<text class="arrowhead"></text>
					</view>
				</view>
				<view class="procedure">
					<view class="items" @tap="toOrderListPage" data-sts="1">
						<image src="/static/user/toPay.png"></image>
						<text>待支付</text>
						<text class="num-badge" v-if="orderAmount.unPay > 0">{{ orderAmount.unPay }}</text>
					</view>
					<view class="items" @tap="toOrderListPage" data-sts="2">
						<image src="/static/user/toDelivery.png"></image>
						<text>待发货</text>
						<text class="num-badge" v-if="orderAmount.payed > 0">{{ orderAmount.payed }}</text>
					</view>
					<view class="items" @tap="toOrderListPage" data-sts="3">
						<image src="/static/user/toTake.png"></image>
						<text>待收货</text>
						<text class="num-badge" v-if="orderAmount.consignment > 0">{{ orderAmount.consignment }}</text>
					</view>
					<view class="items" @tap="toOrderListPage" data-sts="5">
						<image src="/static/user/toComment.png"></image>
						<text>已完成</text>
					</view>
				</view>
			</view>
			<!--end 订单状态 -->

			<view class="prod-col">
				<view class="col-item">
					<view class="num">{{ isLogin ? Math.floor(Math.random() * 20) : '-' }}</view>
					<view class="tit">我的收藏</view>
				</view>
				<view class="col-item">
					<view class="num">{{ isLogin ? Math.floor(Math.random() * 20) : '-' }}</view>
					<view class="tit">我的消息</view>
				</view>
				<view class="col-item">
					<view class="num">{{ isLogin ? Math.floor(Math.random() * 20) : '-' }}</view>
					<view class="tit">我的足迹</view>
				</view>
			</view>

			<view class="my-menu">
				<view class="memu-item">
					<view class="i-name">
						<image src="/static/user/promotion.png"></image>
						<text>分销中心</text>
					</view>
					<view class="arrowhead"></view>
				</view>
				<view class="memu-item">
					<view class="i-name">
						<image src="/static/user/getCoupon.png"></image>
						<text>领券中心</text>
					</view>
					<view class="arrowhead"></view>
				</view>
				<view class="memu-item" >
					<view class="i-name">
						<image src="/static/user/myCoupon.png"></image>
						<text>我的优惠券</text>
					</view>
					<view class="arrowhead"></view>
				</view>
				<view class="memu-item">
					<view class="i-name">
						<image src="/static/user/myAddr.png"></image>
						<text>收货地址</text>
					</view>
					<view class="arrowhead"></view>
				</view>
			</view>
			<!--end 列表项 -->

			<view class="log-out" @click="logout">
				<view class="log-out-n">
					<text>退出登录</text>
				</view>
			</view>
		</view>

	</view>
</template>
  
<script>
import { mapState, mapActions, mapGetters } from 'vuex';
export default {
	data() {
		return {
			orderAmount: '',
			sts: '',
			collectionCount: 0,
			isAuthInfo: false,
			loginResult: {},
		};
	},
	computed: {
		...mapState({
			userInfo: (state) => state.user.userInfo
		}),
		...mapGetters({
			isLogin: 'user/isLogin'
		})
	},
	created() { },
	mounted() { },
	methods: {
		...mapActions({
			logOut: 'user/logout'
		}),
		toLogin() {
			uni.navigateTo({
				url: '/subIndexPages/user/login'
			});
		},
		async logout() {
			const { code } = await this.logOut()
			if (code == 200) {
				// uni.navigateTo({
				// 	url: '/subIndexPages/user/login'
				// });
				uni.showToast({
					title: '退出成功',
					icon: 'none'
				})
			}
		},
	},
};
</script> 
  
<style lang="scss" scoped>
// page {
// 	background-color: #f7f7f7;
// 	padding-bottom: 60rpx;
// }

/* 用户信息 */
.userinfo {
	position: relative;
	width: 100%;
	background: #fff;
	text-align: center;
	padding: 30rpx 0;
}

.userinfo .userinfo-con {
	width: 240rpx;
	margin: auto;
}

.userinfo .userinfo-con .userinfo-avatar {
	overflow: hidden;
	display: block;
	width: 160rpx;
	height: 160rpx;
	border-radius: 50%;
	box-shadow: 3px 3px 10px rgba(0, 0, 0, 0.2);
	margin: auto;
}

.userinfo .userinfo-con .userinfo-avatar image {
	width: 160rpx;
	height: 160rpx;
}

.userinfo .userinfo-con .userinfo-name {
	font-size: 30rpx;
	font-weight: bold;
	margin-top: 20rpx;
	overflow: hidden;
	display: -webkit-box;
	-webkit-line-clamp: 1;
	-webkit-box-orient: vertical;
	text-overflow: ellipsis;
	word-break: break-all;
}

/** 未登录信息 */
.userinfo-none {
	display: flex;
	padding: 30rpx;
	background: #fff;
	align-items: center;
}

.userinfo-none .default-pic {
	padding-right: 30rpx;
}

.userinfo-none .default-pic image {
	width: 160rpx;
	height: 160rpx;
}

.none-login button {
	background: #fff;
}

.none-login button::after {
	border: 0;
}

.none-login .unlogin {
	font-size: 30rpx;
}

.none-login .click-login {
	font-size: 26rpx;
	color: #777;
}

.none-login .unlogin,
.none-login .click-login {
	text-align: left;
	padding: 0;
}

.binding-phone {
	position: relative;
	background: #fff;
	height: 80rpx;
	line-height: 80rpx;
	padding: 0 30rpx;
	border-top: 2rpx solid #f7f7f7;
	border-bottom: 2rpx solid #f7f7f7;
}

.binding-phone .show-tip {
	font-size: 26rpx;
}

.binding-phone .gotobinding {
	border-radius: 8rpx;
	font-size: 28rpx;
	color: #e24b4b;
	font-weight: bold;
}

/*end 用户信息 */

/* 订单状态 */

.list-cont {

	width: 100%;
	background: #f7f7f7;
	margin-top: 20rpx;
}

.list-cont .total-order {
	/* width: 100%; */
	/* margin-bottom: 30rpx; */
	background: #fff;

}

.list-cont .total-order .order-tit {
	display: flex;
	justify-content: space-between;
	height: 80rpx;
	line-height: 80rpx;
	font-size: 30rpx;
	border-bottom: 1px solid #f7f7f7;
	padding: 0 30rpx;
}

.list-cont .total-order .order-tit .checkmore {
	font-size: 22rpx;
	color: #80848f;
	display: flex;
	align-items: center;
}

.list-cont .total-order .procedure {
	display: flex;
	justify-content: space-around;
	align-items: center;
	font-size: 25rpx;
	height: 160rpx;
}

.list-cont .total-order .procedure .items {
	position: relative;
	display: flex;
	flex-direction: column;
	align-items: center;
}

.list-cont .total-order .procedure .items image {
	width: 70rpx;
	height: 70rpx;
	margin-bottom: 20rpx;
}

.list-cont .total-order .procedure .items .num-badge {
	position: absolute;
	top: -15rpx;
	right: -12rpx;
	color: #eb2444;
	border: 3rpx solid #eb2444;
	border-radius: 50rpx;
	background: #fff;
	min-width: 30rpx;
	height: 30rpx;
	line-height: 30rpx;
	text-align: center;
	padding: 2rpx;
	display: block;
}

/* end 订单状态 */

/* 列表项 */

.list-cont .my-menu {
	/* width: 100%; */
	background-color: #fff;
	margin-top: 20rpx;
}

.list-cont .my-menu .memu-item {
	display: flex;
	align-items: center;
	justify-content: space-between;
	height: 100rpx;
	border-bottom: 2rpx solid #f7f7f7;
	padding: 0 30rpx;
}

.list-cont .my-menu .memu-item:nth-child(1) {
	border-top: 2rpx solid #f7f7f7;
}

.list-cont .my-menu .memu-item:last-child {
	border-bottom: none;
}

.list-cont .my-menu .memu-item text {
	font-size: 28rpx;
}

.list-cont .my-menu .memu-item image {
	width: 50rpx;
	height: 50rpx;
	margin-right: 20rpx;

}

.list-cont .my-menu .memu-item .i-name {
	display: flex;
	align-items: center;
}

/* end 列表项 */

/* 箭头 */

.arrowhead {
	width: 15rpx;
	height: 15rpx;
	border-top: 2rpx solid #999;
	border-right: 2rpx solid #999;
	transform: rotate(45deg);
	margin-left: 10rpx;
}


/* 商品收藏消息等 */
.prod-col {
	margin-top: 20rpx;
	background: #fff;
	display: flex;
	justify-content: space-around;
	padding: 30rpx 0 10rpx 0;
	font-size: 12px;
}

.prod-col .col-item {
	text-align: center;
}

.prod-col .col-item .num {
	font-size: 16px;
	font-weight: 700;
	color: #3a86b9;
}

.prod-col .col-item .tit {
	line-height: 34px;
}

/* 退出登录 */
.log-out {
	padding: 20rpx;
	text-align: center;
	margin-top: 20rpx;
}

.log-out-n {
	font-size: 30rpx;
	margin: auto;
	width: 200rpx;
	padding: 20rpx;
	border-radius: 10rpx;
	background: #e43130;
	color: #ffffff;
}

button.memu-btn.memu-item {
	background-color: #fff;
}

button.memu-btn.memu-item:after {
	border: 0;
}
</style>
  
  